#include <stdlib.h>
#include <string.h>

int evalRPN(char ** tokens, int tokensSize){
    int *stack = (int *)malloc(sizeof(int) * tokensSize);
    int top = -1;
    for (int i = 0; i < tokensSize; i++) {
        char *token = tokens[i];
        if (strcmp(token, "+") == 0) {
            stack[top - 1] += stack[top];
            top--;
        } else if (strcmp(token, "-") == 0) {
            stack[top - 1] -= stack[top];
            top--;
        } else if (strcmp(token, "*") == 0) {
            stack[top - 1] *= stack[top];
            top--;
        } else if (strcmp(token, "/") == 0) {
            stack[top - 1] /= stack[top];
            top--;
        } else {
            stack[++top] = atoi(token);
        }
    }
    int result = stack[0];
    free(stack);
    return result;
}
